home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Dreamweaver 3 / Configuration / Behaviors / Actions / Call JavaScript.js < prev    next >
Encoding:
Text File  |  1999-12-01  |  1.5 KB  |  71 lines

  1. // Copyright 1998 Macromedia, Inc. All rights reserved.
  2.  
  3. //*************** GLOBALS VARS *****************
  4.  
  5. var helpDoc = MM.HELP_behCallJavaScript;
  6.  
  7. //******************* BEHAVIOR FUNCTION **********************
  8.  
  9. //Evals a JavaScript string.
  10. //browser window. Passed the following arg:
  11. //  jsStr - a string
  12.  
  13. function MM_callJS(jsStr) { //v2.0
  14.   return eval(jsStr)
  15. }
  16.  
  17.  
  18. //******************* API **********************
  19.  
  20.  
  21. //Can be used with any tag and any event
  22.  
  23. function canAcceptBehavior(){
  24.   return true;
  25. }
  26.  
  27.  
  28.  
  29. //Returns a Javascript function to be inserted in HTML head with script tags.
  30.  
  31. function behaviorFunction(){
  32.   return "MM_callJS";
  33. }
  34.  
  35.  
  36.  
  37. //Returns fn call to insert in HTML tag <TAG... onEvent='thisFn(arg)'>
  38. //Calls escQuotes to find embedded quotes and precede them with \
  39.  
  40. function applyBehavior() {
  41.   var jsStr = escQuotes(document.theForm.message.value);
  42.   if (jsStr == '') {
  43.     return MSG_NoMsg;
  44.   } else {
  45.     return "MM_callJS('" + jsStr + "')";
  46.   }
  47. }
  48.  
  49.  
  50.  
  51. //Passed the function call above, takes prior arguments and reloads the UI.
  52. //Removes any escape characters \
  53.  
  54. function inspectBehavior(jsStr){
  55.   var startPos = jsStr.indexOf("(")+2;
  56.   var endPos = jsStr.lastIndexOf(")",jsStr.length)-1;
  57.   document.theForm.message.value = unescQuotes(jsStr.substring(startPos,endPos));
  58. }
  59.  
  60.  
  61.  
  62. //***************** LOCAL FUNCTIONS  ******************
  63.  
  64.  
  65. //Set the insertion point
  66.  
  67. function initializeUI(){
  68.   document.theForm.message.focus(); //set focus on textbox
  69.   document.theForm.message.select(); //set insertion point into textbox
  70. }
  71.